package com.mryang.ladder;

import java.util.Scanner;

/**
 * @ClassName L1_008
 * @Description TODO 打印两个数字间的所有整数及总和
 * @Author Genius
 * @Date 2021/1/20 18:50
 */
public class L1_008 {
    public static void main(String[] args) {
        Scanner scr = new Scanner(System.in);
        int number1,number2;
        int count = 0; // 计数
        int sum = 0; // 总和
        number1 = scr.nextInt();
        number2 = scr.nextInt();

        for(int i = number1;i <= number2;i++){
            if(i<0){
                System.out.printf("%5d",i);
            }else {
                System.out.printf("%5d",i);
            }
            sum = sum + i;
            count++;
            if(count % 5 == 0 && number2-number1!=4) { // 当两个数间之间刚好5个数则不需要换行
                System.out.print("\n");
            }
        }
        System.out.println("\n"+ "Sum = " +sum);
    }
}
